/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.apache.james.mailbox.cassandra;

//import org.apache.hadoop.hbase.util.Bytes;

import java.nio.ByteBuffer;
import org.apache.cassandra.utils.ByteBufferUtil;

/**
 * Contains table names, column family names, qualifier names and other constants
 * for use in HBase.
 *     
 * Each qualifier in the META column will begin with a short prefix that will
 * determine it's purpose. </br>
 * Qualifier prefix meaning:<br/>
 * <ul>
 * <li> m: meta information; </li>
 * <li> sf: system flag (DELETE, RECENT, etc.) </li>
 * <li> uf: user flag </li>
 * <li> p: user property</li>
 * </ul>
 */
public interface CNames {

    /**
     * The HBase table name for storing mailbox names
     */
    public static final String MAILBOXES = "JAMES_MAILBOXES";
    public static final ByteBuffer MAILBOXES_TABLE = ByteBufferUtil.bytes(MAILBOXES);
    /* Default mailbox column family */
    public static final ByteBuffer MAILBOX_CF = ByteBufferUtil.bytes("M_DATA");
    /* HBase column qualifiers: field names stored as byte arrays*/
    
    public static final ByteBuffer MAILBOX_NAME = ByteBufferUtil.bytes("name");
    public static final ByteBuffer MAILBOX_USER = ByteBufferUtil.bytes("user");
    public static final ByteBuffer MAILBOX_NAMESPACE = ByteBufferUtil.bytes("namespace");
    public static final ByteBuffer MAILBOX_LASTUID = ByteBufferUtil.bytes("lastUID");
    public static final ByteBuffer MAILBOX_UIDVALIDITY = ByteBufferUtil.bytes("uidValidity");
    public static final ByteBuffer MAILBOX_HIGHEST_MODSEQ = ByteBufferUtil.bytes("hModSeq");
    public static final ByteBuffer MAILBOX_MESSAGE_COUNT = ByteBufferUtil.bytes("count");
    public static final String keyspace="keyspace1";
    /** The HBase table name for storing subscriptions */
    public static final String SUBSCRIPTIONS = "JAMES_SUBSCRIPTIONS";
    /** The HBase table name for storing subscriptions */
    public static final ByteBuffer SUBSCRIPTIONS_TABLE = ByteBufferUtil.bytes(SUBSCRIPTIONS);
    /** Default subscription column family */
    public static final ByteBuffer SUBSCRIPTION_CF = ByteBufferUtil.bytes("S_DATA");
    
    //***********added by me
    
    public static final ByteBuffer SUBCRIPTION_USER=ByteBufferUtil.bytes("user");
      public static final ByteBuffer SUBCRIPTION_MAILBOX=ByteBufferUtil.bytes("mailbox");
    
    
    
    /** The HBase table name for storing messages */
    public static final String MESSAGES = "JAMES_MESSAGES";
    
    
    
    public static final String MESSAGES_DATA = "JAMES_MESSAGES_DATA"; // column for message data cf
    
    public static final String MESSAGES_DATA_HEADER = "JAMES_MESSAGES_HEADER"; // column for message data header cf
     
     
     
    /** The HBase table name for storing messages */
    
    public static final ByteBuffer MESSAGES_TABLE = ByteBufferUtil.bytes(MESSAGES);
    
    /* Column family for storing message data*/
    //public static final byte[] MESSAGES_DATA_CF = Bytes.toBytes("DATA");
    /* Column family for storing message meta information*/
    
    public static final ByteBuffer MESSAGES_META_CF = ByteBufferUtil.bytes("META");
    
    /** Column family for storing message headers*/
    
    public static final ByteBuffer MESSAGE_DATA_HEADERS = ByteBufferUtil.bytes("HEAD");
    
    /** Column family for storing message body*/
    
    public static final ByteBuffer MESSAGE_DATA_BODY = ByteBufferUtil.bytes("BODY");
    
    
    public static final String PREFIX_META = "m:";
    public static final ByteBuffer PREFIX_META_B = ByteBufferUtil.bytes(PREFIX_META);
    /** kept sorted */
    public static final ByteBuffer MESSAGE_BODY_OCTETS = ByteBufferUtil.bytes(PREFIX_META + "body");
    public static final ByteBuffer MESSAGE_CONTENT_OCTETS = ByteBufferUtil.bytes(PREFIX_META + "content");
    public static final ByteBuffer MESSAGE_INTERNALDATE = ByteBufferUtil.bytes(PREFIX_META + "date");
    public static final ByteBuffer MESSAGE_TEXT_LINE_COUNT = ByteBufferUtil.bytes(PREFIX_META + "lcount");
    public static final ByteBuffer MESSAGE_MODSEQ = ByteBufferUtil.bytes(PREFIX_META + "mseq");
    public static final ByteBuffer MESSAGE_MEDIA_TYPE = ByteBufferUtil.bytes(PREFIX_META + "mtype");
    public static final ByteBuffer MESSAGE_SUB_TYPE = ByteBufferUtil.bytes(PREFIX_META + "stype");
    public static final ByteBuffer MARKER_PRESENT = ByteBufferUtil.bytes("X");
    public static final ByteBuffer MARKER_MISSING = ByteBufferUtil.bytes(" ");
    public static final ByteBuffer MESSAGE_DATA= ByteBufferUtil.bytes("");
        public static final ByteBuffer FLAGS_ANSWERED = ByteBufferUtil.bytes("sf:A");
    public static final ByteBuffer FLAGS_DELETED = ByteBufferUtil.bytes("sf:DE");
    public static final ByteBuffer FLAGS_DRAFT = ByteBufferUtil.bytes("sf:DR");
    public static final ByteBuffer FLAGS_FLAGGED = ByteBufferUtil.bytes("sf:F");
    public static final ByteBuffer FLAGS_RECENT = ByteBufferUtil.bytes("sf:R");
    public static final ByteBuffer FLAGS_SEEN = ByteBufferUtil.bytes("sf:S");
    public static final ByteBuffer FLAGS_USER = ByteBufferUtil.bytes("sf:U");

    // the maximum recomended HBase column size is 10 MB
    public static final int MAX_COLUMN_SIZE = 1024; //2 * 1024 * 1024;
}
